/*
 * @Author: 13177709051 3506463075@qq.com
 * @Date: 2024-11-06 18:09:34
 * @LastEditors: 13177709051 3506463075@qq.com
 * @LastEditTime: 2024-11-06 18:24:18
 * @FilePath: /linux31/test.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <iostream>
#include <sstream>
#include <string>
#include <jsoncpp/json/json.h>

int main()
{
    const char *name = "小明";
    int age = 19;
    float score[] = {77.5, 88, 99.5};
    
    Json::Value val;
    val["姓名"] = name;
    val["年龄"] = age;
    val["成绩"].append(score[0]);
    val["成绩"].append(score[1]);
    val["成绩"].append(score[2]);

    // 创建StreamWriterBuilder，并禁用Unicode转义
    Json::StreamWriterBuilder swb;
    swb.settings_["encodeUnicode"] = "false";  // 禁用 Unicode 转义

    std::unique_ptr<Json::StreamWriter> sw(swb.newStreamWriter());
    std::stringstream ss;
    int ret = sw->write(val, &ss);
    if (ret != 0)
    {
        std::cout << "write failed!\n";
        return -1;
    }
    std::cout << ss.str() << std::endl;

    return 0;
}

